//
//  LogManager.swift
//  CHT
//
//  Created by aiquantong on 2019/2/20.
//  Copyright © 2019 difan. All rights reserved.
//

import UIKit
import XCGLogger

let log = XCGLogger.default

class LogManager: NSObject {
    
    private static let _sharedInstance = LogManager()
    private var logURL : URL?
    
    class func share() -> LogManager {
        return _sharedInstance;
    }
    
    override public init (){
        super.init();
        let cachePath = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0]
        logURL = cachePath.appendingPathComponent("log.txt")
    }
    
    public var isDebug = false {
        didSet {
            if (isDebug) {
                log.setup(level:.debug, showThreadName:true, showLevel:true, showFileNames:true, showLineNumbers:true, writeToFile:logURL, fileLevel:.debug)
            } else {
                log.setup(level:.error, showThreadName:true, showLevel:true, showFileNames:true, showLineNumbers:true, writeToFile:logURL, fileLevel:.error)
            }
            log.error(Bundle.main.bundlePath);
        }
    }
    
    

}

